package com.itheima.homework.BigDecimal;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class Demo1 {
    public static void main(String[] args) {
        double[] arr = {0.1,0.2,2.1,3.2,5.56,7.21};
        double sum=0;
        for (int i = 0; i < arr.length; i++) {
            sum+=arr[i];
        }
        BigDecimal b=new BigDecimal(sum);
        System.out.println("b = " + b);
        BigDecimal bigDecimal = b.setScale(2, BigDecimal.ROUND_HALF_UP);
        System.out.println("bigDecimal = " + bigDecimal);
    }
}
